import { ref, computed } from 'vue'
import { defineStore } from 'pinia'
import tmenu from '@/router/axios/tmenu'

export const useCounterStore = defineStore('counter', {
    state:()=>({
      username:""
    }),
    getters:{
      islogin:state => state.username!=null&&state.username!=""
    },
    actions:{
      async login(user:any){
        let res = await tmenu.login(user)
        console.log(res);
        if(res.data.code==200){
          this.username=res.data.data.username
        }else{
          alert("登录错误")
        }
      }
    },
    persist:{
    storage:sessionStorage,
  }
})